package com.amazon.trietree.server;

/**
 * Created with IntelliJ IDEA.
 * User: Tylaar
 * Date: 11/7/12
 * Time: 11:54 PM
 * Company: Amazon.com
 */
public class MetaDataStructMonitor {
    private int totalCount = 0;
    private int hashTableSize = 0;
    private int prefixLen = 5;

    private MetaDataLocalServer server;

    public int getPrefixLen() {
        return prefixLen;
    }

    public void setPrefixLen(int prefixLen) {
        this.prefixLen = prefixLen;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getHashTableSize() {
        return hashTableSize;
    }

    public void setHashTableSize(int hashTableSize) {
        this.hashTableSize = hashTableSize;
    }

    public void increaseTotalCountBy(int count){
        totalCount += count;
    }

    public void increaseTotalCountByOne(){
        totalCount++;
    }

    public void increaseTableSizeBy(int count){
        hashTableSize += count;
    }

    public void increaseTableSizeByOne(){
        hashTableSize++;
    }

    public void printStatisticReport(){

        System.out.println("====================Report======================");
        System.out.println(" Total fp num: " + totalCount);
        System.out.println(" Total fp shall cost mem:" + totalCount * prefixLen);
        System.out.println(" Total hash size: " + hashTableSize);
        System.out.println(" Saved size: " + ( totalCount - hashTableSize ) * prefixLen + "Bytes" ) ;
        System.out.println(" Saving percentage: " + (double)(totalCount - hashTableSize) * 100.0/totalCount + "%");
        System.out.println("======================End=======================");
    }

    public MetaDataLocalServer getServer() {
        return server;
    }

    public void setServer(MetaDataLocalServer server) {
        this.server = server;
    }
}
